<?php
set_time_limit(0);
include("../config.php");

// This file shows how to play all MP3's from a release
// It searches a cached sandbox list for an artist, and returns an oauth mp3 link that is converted to a player
// Created 27th November 2012
// Modified 28th November 2012
// dan.brown180@emimusic.com

echo "<select name = \"input_artist\" id = \"input_artist\" onchange=\"window.location='artist.php?input_artist='+this.value;\">
";
echo "<option value = \"\" selected=selected>Select an artist...</option>";
$result = mysql_query("SELECT DISTINCT(`artist_name`) FROM `$sandbox_key` ORDER BY `artist_name` ASC") or die(mysql_error());  
while($row = mysql_fetch_array($result))
{
$artist_name = $row['artist_name'];
if ($artist_name != "")
{
echo "<option value = \"$artist_name\">$artist_name</option>
";
}
}
echo "</select><Br>
";
$input_artist=$_GET['input_artist'];
if ($input_artist != "")
{
echo "<select name = \"release\" id = \"release\" onchange=\"window.location='artist.php?input_artist=$input_artist&release='+this.value;\">
";
echo "<option value = \"\" selected=selected>Select a release...</option>";
$result = mysql_query("SELECT DISTINCT(`release`) FROM `$sandbox_key` WHERE `artist_name` = \"$input_artist\" ORDER BY `release` ASC") or die(mysql_error());  
while($row = mysql_fetch_array($result))
{
$release = $row['release'];
if ($artist_name != "")
{
echo "<option value = \"$release\">$release</option>
";
}
}
echo "</select><Br>
";
}

$release = $_GET['release'];

if ($release != "")
{
$result = mysql_query("SELECT * FROM `$sandbox_key` WHERE `artist_name` = \"$input_artist\" && `type` = 'audio' && `release` = \"$release\" LIMIT 25") or die(mysql_error());  
while($row = mysql_fetch_array($result)) 
{
$mp3 = $row['file_asset_id'];
$title = $row['title'];
$assetdata = $sandboxApi->access($mp3); // convert file_asset_id to a streaming mp3 link authenticated through oauth
$mp3 = $assetdata['assets'][0]['url'];
echo "<a href = \"$mp3\">$title</a><Br>";
}
}
?>
<script type="text/javascript" src="http://webplayer.yahooapis.com/player.js"></script>